﻿using System;
using System.Collections.Generic;
using System.Text;
using PreguntaAlExperto.TransporterObjectsFramework;
using PreguntaAlExperto.RulesLayer.Entities;
using PreguntaAlExperto.ObjectMapper;
using PreguntaAlExperto.ObjectMapper.DTO;
using PreguntaAlExperto.ObjectMapper.Helper;
using System.Collections;

namespace PreguntaAlExperto.RulesLayer.Services
{
    public class PairService
    {
        private const int ID_COLUMN = 0;
        private const int NAME_COLUMN = 1;

        public enum enuPairList
        { 
            Languages = 0,
            Skills = 1,
            Platforms = 2,
            Technologies = 3
        }

        public BaseList<Pair> getPairList(enuPairList _list)
        {
            PairDTO _DTO = new PairDTO();

            switch (_list)
            { 
                case enuPairList.Languages:
                    return ((BaseList<Pair>)_DTO.Select("SQL_SELECT_PAIR_LANGUAGES", null));
                    break;
                case enuPairList.Platforms:
                    return ((BaseList<Pair>)_DTO.Select("SQL_SELECT_PAIR_PLATFORMS", null));
                    break;
                case enuPairList.Skills:
                    return ((BaseList<Pair>)_DTO.Select("SQL_SELECT_PAIR_SKILLS", null));
                    break;
                case enuPairList.Technologies:
                    return ((BaseList<Pair>)_DTO.Select("SQL_SELECT_PAIR_TECHNOLOGIES", null));
                    break;
                default:
                    return null;
            }
        }

        public static BaseList<Pair> ToBaseList(object[] values)
        {
            BaseList<Pair> ret = new BaseList<Pair>();

            foreach (object row in values)
            {
                ret.Add(new Pair (){ 
                    ID = int.Parse(((ArrayList)row)[ID_COLUMN].ToString()),
                    Name = ((ArrayList)row)[NAME_COLUMN].ToString()
                });
            }

            return ret;  
        }

    }
}
